/**
  ******************************************************************************
  * @file    motor.h
  * @brief   编码电机驱动头文件，电机驱动为TB6612
  * @version V1.0.0
  * @date    2025-07-15
  ******************************************************************************
  */

#ifndef __MOTOR_H__
#define __MOTOR_H__

#include "main.h"
#include "tim.h"
#include <stdint.h>

#define MOTER_ABS(a)	((a>0)?(a):(-a))	//绝对值宏函数
/* ========================= 用户配置参数区 ========================= */
#define motor_TIM			        htim3
#define motor1_TIM_CHANNEL    TIM_CHANNEL_1
#define motor2_TIM_CHANNEL    TIM_CHANNEL_2
#define motor3_TIM_CHANNEL    TIM_CHANNEL_3
#define motor4_TIM_CHANNEL    TIM_CHANNEL_4

#define MOTER1_PIN_1(level)		HAL_GPIO_WritePin(GPIOF, GPIO_PIN_3, (GPIO_PinState)level)
#define MOTER1_PIN_2(level)		HAL_GPIO_WritePin(GPIOF, GPIO_PIN_4, (GPIO_PinState)level)
#define MOTER2_PIN_1(level)		HAL_GPIO_WritePin(GPIOF, GPIO_PIN_5, (GPIO_PinState)level)
#define MOTER2_PIN_2(level)		HAL_GPIO_WritePin(GPIOF, GPIO_PIN_6, (GPIO_PinState)level)
#define MOTER3_PIN_1(level)		HAL_GPIO_WritePin(GPIOF, GPIO_PIN_7, (GPIO_PinState)level)
#define MOTER3_PIN_2(level)		HAL_GPIO_WritePin(GPIOF, GPIO_PIN_8, (GPIO_PinState)level)
#define MOTER4_PIN_1(level)		HAL_GPIO_WritePin(GPIOF, GPIO_PIN_9, (GPIO_PinState)level)
#define MOTER4_PIN_2(level)		HAL_GPIO_WritePin(GPIOF, GPIO_PIN_10, (GPIO_PinState)level)


void motor12_init(void);
void motor34_init(void);
void Moter_SetSpeed(short speed1, short speed2, short speed3, short speed4);
#endif
